<template>
  <div class="home">
    <van-nav-bar :title="deviceName" left-arrow @click-left="onClickLeft" />
    <div class="home-content">
      <p class="home-content-area-text">功能列表</p>
      <transition-group tag="ul" class="home-content-info">
        <li
          class="home-content-info-item"
          @click="onItem(item, index)"
          v-for="(item, index) in infoData"
          :key="item"
        >
          <img class="home-content-info-item-img" :src="item.Icon" alt="" />
          <div class="home-content-info-item-title">
            <p class="home-content-info-item-title-name">{{ item.name }}</p>
          </div>
        </li>
      </transition-group>
    </div>
  </div>
</template>

<script>
export default {
  components: {},
  name: "FailDetect_1_index",
  mounted: function () {
    console.log("mqtt");
    this.initInterface();
    // this.mqttMsg();
    // this.myEcharts();
  },
  data: function () {
    return {
      paramsRes: "",
      mqttData: "",
      tableData: [],
      infoData: [
        {
          Icon: require("@/assets/img/position.svg"),
          name: "设备状态",
          data: "--",
          router: "express1_position",
        },
        // {
        //   Icon: require("@/assets/img/enclosure.svg"),
        //   name: "电子围栏",
        //   data: "--",
        //   router: "position2_enclosure"
        // },
        // {
        //   Icon: require("@/assets/img/track.svg"),
        //   name: "历史轨迹",
        //   data: "--",
        //   router: "FailDetect_1_track",
        // },
      ],
      deviceName: "",
    };
  },
  activated: function () {},
  methods: {
    initInterface() {
      this.paramsRes = this.$route.params;
      
      this.mqttData = this.paramsRes.mqttMsg;
      console.log(this.mqttData)
      this.deviceName = this.paramsRes.deviceInfo.scribe;
    },
    onClickLeft() {
      this.$router.go(-1);
    },
    onItem(item, index) {
      console.log(item);
      this.$router.push({
        name: item.router,
        params: {
          mqttMsg: this.$route.params.mqttMsg,
          deviceInfo: this.$route.params.deviceInfo,
          routerType: "push",
        },
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.v-enter,
.v-leave-to {
  opacity: 0;
  transform: translateX(100px);
}

.v-enter-active,
.v-leave-to {
  transition: all 0.6s ease;
}

/* v-move 和 v-leave-to 配合使用，能够实现列表后续的元素，逐渐飘上来的效果 */
.v-move {
  transition: all 0.6s ease;
}

.v-leave-to {
  position: absolute;
}
.home {
  width: 100%;
  height: 100%;
  overflow: auto;
  display: flex;
  flex-flow: column;
  position: absolute;
  &-content {
    height: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: left;
    justify-content: left;
    transition: 0.3s;
    overflow-x: hidden;
    &-echarts {
      transition: 0.5s;
      text-align: center;
      margin: 0 16px 15px;
      border-radius: 20px 20px 20px 20px;
      width: auto;
      height: 40vh;
      display: flex;
      position: relative;
      flex-direction: column;
      justify-content: left;
      background-color: rgba(255, 255, 255, 0.9);
      background-attachment: fixed;
    }
    &-control {
      border-radius: 20px;
      margin-top: 0px;
      margin-left: 20px;
      margin-right: 20px;
      margin-bottom: 20px;
    }
    &-area {
      &-text {
        margin-left: 20px;
        font-size: 5vw;
        color: white;
        font-weight: 900;
      }
    }
    &-text {
      margin: px2rem(20);
      font-size: px2rem(30);
      color: white;
      font-weight: 600;
      margin-bottom: px2rem(30);
    }
    &-shebei {
      margin-left: px2rem(20);
      margin-bottom: px2rem(5);
      font-size: px2rem(14);
      color: white;
      font-weight: 400;
    }
    &-info {
      transition: 0.5s;
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      padding: 0 16px 0 16px;

      &-item {
        transition: 0.5s;
        margin: 5px;
        text-align: center;
        padding: 5px;
        border-radius: 20px 20px 20px 20px;
        // box-shadow: 0 0 16px 0 rgba(0, 0, 0, 0.3);
        width: calc(50% - 20px);
        // height: calc(50% - 10px);
        display: flex;
        position: relative;
        flex-direction: column;
        justify-content: left;
        background-color: rgba(255, 255, 255, 0.9);
        background-attachment: fixed;
        &-title {
          display: flex;
          flex-direction: row;
          align-items: center;

          &-name {
            margin: auto;
            transition: 0.5s;
            text-align: left;
            color: black;
            //margin-top: 0;
            font-size: 4vw;
          }
        }

        &-img {
          padding: 10px;
          transition: 0.5s;
          // text-align: right;
          color: black;
          margin: auto;
          width: 50%;
        }
      }
    }
  }
}
.custom-button {
  width: auto;
  padding: 5px 10px;
  color: #fff;
  font-size: 4vw;
  line-height: 5vw;
  text-align: center;
  background-color: #0aadee;
  border-radius: 20px;
}
</style>
